package com.cjbdi.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.hibernate.SQLQuery;
import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cjbdi.util.NumUtil;


/**
 * HeadService
 */
@Service
@Transactional
public class HeadService{
	@Autowired  
    @PersistenceContext  
    private EntityManager entityManager;// 注入EntityManager实例 
	//概述（和去年同比） 
	public List getGsList(String kind, String type, String date, String fybm){ 
    	Query query = entityManager.createNativeQuery("SELECT\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN ( xs + jc ) ELSE 0 END ) AS yearsl,\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+date+"' THEN ( xs + jc ) ELSE 0 END )=0 THEN 999999 ELSE (cast( sum( CASE WHEN date = '"+date+"' THEN yj ELSE 0 END ) AS FLOAT ) / sum( CASE WHEN date = '"+date+"' THEN ( xs + jc ) ELSE 0 END ) * 100) END) AS jal," + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs ELSE 0 END ) AS lastyearxs,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs ELSE 0 END ) AS yearxs,\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs ELSE 0 END )=0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs ELSE 0 END ) AS FLOAT ) * 100 END) AS xstb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN jc ELSE 0 END ) AS lastyearjc,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN jc ELSE 0 END ) AS yearjc,\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN jc ELSE 0 END )=0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN jc ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN jc ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN jc ELSE 0 END ) AS FLOAT ) * 100 END) AS jctb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN yj ELSE 0 END ) AS lastyearyj,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN yj ELSE 0 END ) AS yearyj,\r\n" + 
    			"\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN yj ELSE 0 END )=0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN yj ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN yj ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN yj ELSE 0 END ) AS FLOAT ) * 100  END) AS yjtb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xsaj ELSE 0 END ) AS lastyearxsxs,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_xsaj ELSE 0 END ) AS yearxsxs,\r\n" + 
    			"\r\n" + 
    			"  (CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xsaj ELSE 0 END )=0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_xsaj ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xsaj ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xsaj ELSE 0 END ) AS FLOAT ) * 100 END) AS xsxstb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_msaj ELSE 0 END ) AS lastyearxsms,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_msaj ELSE 0 END ) AS yearxsms,\r\n" + 
    			"	\r\n" + 
    			"	 (CASE WHEN  sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_msaj ELSE 0 END ) =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_msaj ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_msaj ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_msaj ELSE 0 END ) AS FLOAT ) * 100 END) AS xsmstb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xzaj ELSE 0 END ) AS lastyearxsxz,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_xzaj ELSE 0 END ) AS yearxsxz,\r\n" + 
    			"	\r\n" + 
    			"	 (CASE WHEN  sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xzaj ELSE 0 END ) =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_xzaj ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xzaj ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_xzaj ELSE 0 END ) AS FLOAT ) * 100 END) AS xsxztb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zxaj ELSE 0 END ) AS lastyearzx,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_zxaj ELSE 0 END ) AS yearzx,\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN  sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zxaj ELSE 0 END ) =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_zxaj ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zxaj ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zxaj ELSE 0 END ) AS FLOAT ) * 100 END) AS zxtb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_ys ELSE 0 END ) AS lastyearys,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_ys ELSE 0 END ) AS yearys,\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_ys ELSE 0 END ) =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_ys ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_ys ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_ys ELSE 0 END ) AS FLOAT ) * 100 END) AS ystb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_es ELSE 0 END ) AS lastyeares,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_es ELSE 0 END ) AS yeares,\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_es ELSE 0 END )  =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_es ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_es ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_es ELSE 0 END ) AS FLOAT ) * 100 END) AS estb,\r\n" + 
    			"	sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zs ELSE 0 END ) AS lastyearzs,\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_zs ELSE 0 END ) AS yearzs,\r\n" + 
    			"	\r\n" + 
    			"	\r\n" + 
    			"	(CASE WHEN sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zs ELSE 0 END ) =0 THEN 999999 ELSE (\r\n" + 
    			"	sum( CASE WHEN date = '"+date+"' THEN xs_zs ELSE 0 END ) - sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zs ELSE 0 END ) \r\n" + 
    			"	) / cast( sum( CASE WHEN date = '"+(Integer.parseInt(date)-1)+"' THEN xs_zs ELSE 0 END ) AS FLOAT ) * 100 END)  AS zstb \r\n" + 
    			"FROM\r\n" + 
    			"	sfzs_result_ajztqk \r\n" + 
    			"WHERE\r\n" + 
    			"	type = '"+type+"' \r\n" + 
    			"	AND date IN ( '"+date+"', '"+(Integer.parseInt(date)-1)+"' ) \r\n" + 
    			"	AND kind = '"+kind+"' \r\n" + 
    			"	AND jbfy= '"+fybm+"'");  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }
	//审限内结案率
	public List getJalList(String kind, String type, String date, String fybm){ 
	    Query query = entityManager.createNativeQuery("select jbfy,sxqnjal,ysjycxsyl from sfzs_result_jal where (type='"+type+"' and date ='"+date+"' and kind='"+kind+"' and jbfy ='"+fybm+"') OR (date ='"+date+"' and fymc='全国')  order by jbfy");  
	    query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
	    List rows = query.getResultList();  
	    return rows;
	}
	//案件、文书质量情况
	public List getAjWsZlList(String type, String date, String fybm){ 
    	Query query = entityManager.createNativeQuery("SELECT\r\n" + 
    			"	* \r\n" + 
    			"FROM\r\n" + 
    			"	(\r\n" + 
    			"SELECT\r\n" + 
    			"	fybm,\r\n" + 
    			"	ajhgl,\r\n" + 
    			"	RANK () OVER ( ORDER BY ajhgl DESC ) AS ajhg_rank,\r\n" + 
    			"	ajfgl,\r\n" + 
    			"	RANK () OVER ( ORDER BY ajfgl DESC ) AS ajfg_rank,\r\n" + 
    			"	ajjsl,\r\n" + 
    			"	RANK () OVER ( ORDER BY ajjsl DESC ) AS ajjs_rank,\r\n" + 
    			"	ajzxd,\r\n" + 
    			"	RANK () OVER ( ORDER BY ajzxd DESC ) AS ajzx_rank,\r\n" + 
    			"	wsgfl,\r\n" + 
    			"	RANK () OVER ( ORDER BY wsgfl DESC ) AS wsgf_rank,\r\n" + 
    			"	wsfgl,\r\n" + 
    			"	RANK () OVER ( ORDER BY wsfgl DESC ) AS wsfg_rank,\r\n" + 
    			"	wszxd,\r\n" + 
    			"	RANK () OVER ( ORDER BY wszxd DESC ) AS wszx_rank,\r\n" + 
    			"	wsjsl,\r\n" + 
    			"	RANK () OVER ( ORDER BY wsjsl DESC ) AS wsjs_rank \r\n" + 
    			"FROM\r\n" + 
    			"	sfzs_result_ajwszl \r\n" + 
    			"WHERE\r\n" + 
    			"	TYPE = '"+type+"' \r\n" + 
    			"	AND DATE = '"+date+"' \r\n" + 
    			"	) T \r\n" + 
    			"WHERE\r\n" + 
    			"	fybm = '"+fybm.substring(0, 1)+"'");  
        query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);  
        List rows = query.getResultList();  
        return rows;
    }

    
    public boolean getheadzs(Map dataMap, String kind, String type, String date, String fybm) {//法官工作量变化指数
    	List gslist = getGsList(kind,type,date,fybm);//获取公开指数概况  
    	dataMap.put("head_jal", "--");
		dataMap.put("head_sl", "--");
		dataMap.put("head_xs", "--");
		dataMap.put("head_xstb", "--");
		dataMap.put("head_jc", "--");
		dataMap.put("head_jctb", "--");
		dataMap.put("head_yj", "--");
		dataMap.put("head_yjtb", "--");
		dataMap.put("head_xsxs", "--");
		dataMap.put("head_xsxstb", "--");
		dataMap.put("head_xsms", "--");
		dataMap.put("head_mstb", "--");
		dataMap.put("head_xsxz", "--");
		dataMap.put("head_xztb", "--");
		dataMap.put("head_zx", "--");
		dataMap.put("head_zxtb", "--");
		dataMap.put("head_xsys", "--");
		dataMap.put("head_xses", "--");
		dataMap.put("head_xszs", "--");
		dataMap.put("head_ystb", "--");
		dataMap.put("head_estb", "--");
		dataMap.put("head_zstb", "--");
		dataMap.put("head_ajhg", "--");	
		
		dataMap.put("head_ajhg_rank", "--");
		dataMap.put("head_ajfg", "--");		
		dataMap.put("head_ajfg_rank", "--");
		dataMap.put("head_ajjs", "--");		
		dataMap.put("head_ajjs_rank", "--");
		dataMap.put("head_ajzx", "--");		
		dataMap.put("head_ajzx_rank", "--");
		
		dataMap.put("head_wsgf", "--");		
		dataMap.put("head_wsgf_rank", "--");
		dataMap.put("head_wsfg", "--");		
		dataMap.put("head_wsfg_rank", "--");
		dataMap.put("head_wsjs", "--");		
		dataMap.put("head_wsjs_rank", "--");
		dataMap.put("head_wszx", "--");		
		dataMap.put("head_wszx_rank", "--");
    	if(gslist.size()>0&&((Map)gslist.get(0)).get("yearxs") != null) {
    		Map row = (Map)gslist.get(0);
    		/*if(Integer.parseInt(row.get("yearxs").toString())<2000) {//收案量小于2000的报告不支持导出
    			return false;
    		}*/
    		dataMap.put("head_jal", NumUtil.toNxiaoshu(row.get("jal").toString(), 2));
    		dataMap.put("head_sl", NumUtil.toWan(Integer.parseInt(row.get("yearsl").toString())));
    		dataMap.put("head_xs", NumUtil.toWan(Integer.parseInt(row.get("yearxs").toString())));
    		if(NumUtil.toNxiaoshu(row.get("xstb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("xstb").toString(),2)==999999) {
    				dataMap.put("head_xstb", "--");
    			}else {
    				dataMap.put("head_xstb", "上升"+NumUtil.toNxiaoshu(row.get("xstb").toString(), 2)+"%");
    			}	
    		}else if(NumUtil.toNxiaoshu(row.get("xstb").toString(),2)<0) {
    			dataMap.put("head_xstb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("xstb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_xstb", "不变");
    		}
    		dataMap.put("head_jc", NumUtil.toWan(Integer.parseInt(row.get("yearjc").toString())));
    		if(NumUtil.toNxiaoshu(row.get("jctb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("jctb").toString(),2)==999999) {
    				dataMap.put("head_jctb", "--");
    			}else {
    				dataMap.put("head_jctb", "上升"+NumUtil.toNxiaoshu(row.get("jctb").toString(), 2)+"%");
    			}
    		}else if(NumUtil.toNxiaoshu(row.get("jctb").toString(),2)<0) {
    			dataMap.put("head_jctb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("jctb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_jctb", "不变");
    		}
    		dataMap.put("head_yj", NumUtil.toWan(Integer.parseInt(row.get("yearyj").toString())));
    		if(NumUtil.toNxiaoshu(row.get("yjtb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("yjtb").toString(),2)==999999) {
    				dataMap.put("head_yjtb", "--");
    			}else {
    				dataMap.put("head_yjtb", "上升"+NumUtil.toNxiaoshu(row.get("yjtb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("yjtb").toString(),2)<0) {
    			dataMap.put("head_yjtb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("yjtb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_yjtb", "不变");
    		}
    		dataMap.put("head_xsxs", NumUtil.toWan(Integer.parseInt(row.get("yearxsxs").toString())));
    		if(NumUtil.toNxiaoshu(row.get("xsxstb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("xsxstb").toString(),2)==999999) {
    				dataMap.put("head_xsxstb", "--");
    			}else {
    				dataMap.put("head_xsxstb", "上升"+NumUtil.toNxiaoshu(row.get("xsxstb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("xsxstb").toString(),2)<0) {
    			dataMap.put("head_xsxstb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("xsxstb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_xsxstb", "不变");
    		}
    		dataMap.put("head_xsms", NumUtil.toWan(Integer.parseInt(row.get("yearxsms").toString())));
    		if(NumUtil.toNxiaoshu(row.get("xsmstb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("xsmstb").toString(),2)==999999) {
    				dataMap.put("head_mstb", "--");
    			}else {
    				dataMap.put("head_mstb", "上升"+NumUtil.toNxiaoshu(row.get("xsmstb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("xsmstb").toString(),2)<0) {
    			dataMap.put("head_mstb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("xsmstb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_mstb", "不变");
    		}
    		dataMap.put("head_xsxz", NumUtil.toWan(Integer.parseInt(row.get("yearxsxz").toString())));
    		if(NumUtil.toNxiaoshu(row.get("xsxztb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("xsxztb").toString(),2)==999999) {
    				dataMap.put("head_xztb", "--");
    			}else {
    				dataMap.put("head_xztb", "上升"+NumUtil.toNxiaoshu(row.get("xsxztb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("xsxztb").toString(),2)<0) {
    			dataMap.put("head_xztb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("xsxztb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_xztb", "不变");
    		}
    		dataMap.put("head_zx", NumUtil.toWan(Integer.parseInt(row.get("yearzx").toString())));
    		if(NumUtil.toNxiaoshu(row.get("zxtb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("zxtb").toString(),2)==999999) {
    				dataMap.put("head_zxtb", "--");
    			}else {
    				dataMap.put("head_zxtb", "上升"+NumUtil.toNxiaoshu(row.get("zxtb").toString(), 2)+"%");
    			}	
    		}else if(NumUtil.toNxiaoshu(row.get("zxtb").toString(),2)<0) {
    			dataMap.put("head_zxtb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("zxtb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_zxtb", "不变");
    		}
    		dataMap.put("head_xsys", NumUtil.toWan(Integer.parseInt(row.get("yearys").toString())));
    		if(NumUtil.toNxiaoshu(row.get("ystb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("ystb").toString(),2)==999999) {
    				dataMap.put("head_ystb", "--");
    			}else {   				
    				dataMap.put("head_ystb", "上升"+NumUtil.toNxiaoshu(row.get("ystb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("ystb").toString(),2)<0) {
    			dataMap.put("head_ystb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("ystb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_ystb", "不变");
    		}
    		dataMap.put("head_xses", NumUtil.toWan(Integer.parseInt(row.get("yeares").toString())));
    		if(NumUtil.toNxiaoshu(row.get("estb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("estb").toString(),2)==999999) {
    				dataMap.put("head_estb", "--");
    			}else {
    				dataMap.put("head_estb", "上升"+NumUtil.toNxiaoshu(row.get("estb").toString(), 2)+"%");
    			}
    			
    		}else if(NumUtil.toNxiaoshu(row.get("estb").toString(),2)<0) {
    			dataMap.put("head_estb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("estb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_estb", "不变");
    		}
    		dataMap.put("head_xszs", row.get("yearzs").toString());
    		if(NumUtil.toNxiaoshu(row.get("zstb").toString(),2)>0) {
    			if(NumUtil.toNxiaoshu(row.get("zstb").toString(),2)==999999) {
    				dataMap.put("head_zstb", "--");
    			}else {
    				dataMap.put("head_zstb", "上升"+NumUtil.toNxiaoshu(row.get("zstb").toString(), 2)+"%");
    			}
    		}else if(NumUtil.toNxiaoshu(row.get("zstb").toString(),2)<0) {
    			dataMap.put("head_zstb", "下降"+(-1)*NumUtil.toNxiaoshu(row.get("zstb").toString(), 2)+"%");
    		}else {
    			dataMap.put("head_zstb", "不变");
    		}
    	}
    	if(kind.equals("高")) {
    		List ajwszlList = getAjWsZlList(type, date, fybm);
    		if(ajwszlList.size()>0) {
    			Map row = (Map)ajwszlList.get(0);
    			dataMap.put("head_ajhg", NumUtil.toNxiaoshu(row.get("ajhgl").toString(), 2));		
    			dataMap.put("head_ajhg_rank", NumUtil.toChineseNum(row.get("ajhg_rank").toString()));
    			dataMap.put("head_ajfg", NumUtil.toNxiaoshu(row.get("ajfgl").toString(), 2));		
    			dataMap.put("head_ajfg_rank", NumUtil.toChineseNum(row.get("ajfg_rank").toString()));
    			dataMap.put("head_ajjs", NumUtil.toNxiaoshu(row.get("ajjsl").toString(), 2));		
    			dataMap.put("head_ajjs_rank", NumUtil.toChineseNum(row.get("ajjs_rank").toString()));
    			dataMap.put("head_ajzx", NumUtil.toNxiaoshu(row.get("ajzxd").toString(), 2));		
    			dataMap.put("head_ajzx_rank", NumUtil.toChineseNum(row.get("ajzx_rank").toString()));
    			
    			dataMap.put("head_wsgf", NumUtil.toNxiaoshu(row.get("wsgfl").toString(), 2));		
    			dataMap.put("head_wsgf_rank", NumUtil.toChineseNum(row.get("wsgf_rank").toString()));
    			dataMap.put("head_wsfg", NumUtil.toNxiaoshu(row.get("wsfgl").toString(), 2));		
    			dataMap.put("head_wsfg_rank", NumUtil.toChineseNum(row.get("wsfg_rank").toString()));
    			dataMap.put("head_wsjs", NumUtil.toNxiaoshu(row.get("wsjsl").toString(), 2));		
    			dataMap.put("head_wsjs_rank", NumUtil.toChineseNum(row.get("wsjs_rank").toString()));
    			dataMap.put("head_wszx", NumUtil.toNxiaoshu(row.get("wszxd").toString(), 2));		
    			dataMap.put("head_wszx_rank", NumUtil.toChineseNum(row.get("wszx_rank").toString()));
    			
    		}
    	}
    	dataMap.put("head_sxqnjal", "--");	
    	dataMap.put("head_sxqnjal_qg", "--");
    	dataMap.put("head_sxqnjal_cz", "--");
    	dataMap.put("head_ysjycxsyl_cz", "--");
    	dataMap.put("head_ysjycxsyl", "--");
    	dataMap.put("head_ysjycxsyl_qg", "--");
		List jalList = getJalList(kind, type, date, fybm);
		if(jalList.size()>1) {
			Map map = new HashMap();
	    	Map mapqg = new HashMap();
	    	map = (Map)jalList.get(0);
	    	mapqg = (Map)jalList.get(1);
	        double sxqnjal = NumUtil.toNxiaoshu(map.get("sxqnjal").toString(), 2);
	        double sxqnjal_qg = NumUtil.toNxiaoshu(mapqg.get("sxqnjal").toString(), 2);
	        double ysjycxsyl = NumUtil.toNxiaoshu(map.get("ysjycxsyl").toString(), 2);
	        double ysjycxsyl_qg = NumUtil.toNxiaoshu(mapqg.get("ysjycxsyl").toString(), 2);
			if(sxqnjal>=sxqnjal_qg) {
				dataMap.put("head_sxqnjal_cz", "高"+NumUtil.toNxiaoshu((sxqnjal-sxqnjal_qg),2));	
			}else if(sxqnjal<sxqnjal_qg){
				dataMap.put("head_sxqnjal_cz", "低"+NumUtil.toNxiaoshu((sxqnjal_qg-sxqnjal),2));	
			}
			if(ysjycxsyl>=ysjycxsyl_qg) {
				dataMap.put("head_ysjycxsyl_cz", "高"+NumUtil.toNxiaoshu((ysjycxsyl-ysjycxsyl_qg),2));	
			}else if(ysjycxsyl<ysjycxsyl_qg){
				dataMap.put("head_ysjycxsyl_cz", "低"+NumUtil.toNxiaoshu((ysjycxsyl_qg-ysjycxsyl),2));	
			}
	        dataMap.put("head_sxqnjal", sxqnjal);	
			dataMap.put("head_sxqnjal_qg", sxqnjal_qg);
			dataMap.put("head_ysjycxsyl", ysjycxsyl);	
			dataMap.put("head_ysjycxsyl_qg", ysjycxsyl_qg);
		}
		return true;
    } 
}
